package com.title5;

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @Author milian
 * @Date 2021/8/2 0002 17:27
 */
public class ServerDemo {
    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket(10000);
        Socket accept = serverSocket.accept();
        InputStream inputStream = accept.getInputStream();
        int b;
        while ((b=inputStream.read())!=-1){
            System.out.println((char)b);
        }
        System.out.println("看看我执行了吗？");
        BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(accept.getOutputStream()));
        bufferedWriter.write("你是谁？");
        bufferedWriter.newLine();
        bufferedWriter.flush();
        bufferedWriter.close();
        inputStream.close();
        accept.close();
        serverSocket.close();
    }
}
